package hot_100;

public class 搜索二维矩阵II {
    public static void main(String[] args) {

    }

    public boolean searchMatrix(int[][] matrix, int target) {
        int n = matrix.length;
        int m = matrix[0].length;
        int stx = 0, sty = m - 1;
        while (sty > 0 && stx < n) {
            if (matrix[stx][sty] == target) {
                return true;
            } else if (matrix[stx][sty] > target) {
                sty--;
            } else {
                stx++;
            }
        }
        return false;
    }
}
